package com.example.dongho;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MySimpleArrayAdapter extends ArrayAdapter<String>{
	
	private final Context context;
	private final String[] values;

	public MySimpleArrayAdapter(Context context, String[] values) {
		super(context, R.layout.item_template, values);
		this.context = context;
		this.values = values;
	}
	@SuppressLint({ "ParserError", "ParserError" })
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
		View view = inflater.inflate(R.layout.item_template, parent, false);
		TextView textView = (TextView) view.findViewById(R.id.textView1);
		TextView textView2 = (TextView) view.findViewById(R.id.textView2);
	    ImageView imageView = (ImageView) view.findViewById(R.id.imageView1);
	    textView.setText(values[position]);
	    String mvalue = values[position];
	    
	    if (mvalue.equals("NAM")) {
			textView2.setText("KAKA");
		}else if (mvalue.equals("Nguyet")) {
			textView2.setText("HIIH");
		}else {
			textView2.setText("");
		}
	    imageView.setImageResource(R.drawable.a);

		return view;
	}
}
